<? if (!isset($advance_of_maney)) $advance_of_maney = 100 ;
$discount_rate = 0;
if ($this->session->userdata('discount_rate')){
	$discount_rate = $this->session->userdata('discount_rate');
}
	


?>
<style>
.ui-state-active{
	background-color:#C6AB79;
}
</style>
<div class="my-account form-container" style="min-height:900px">
<div class="left" style="width: 200px; padding: 20px">
	<h2 style="margin:10px 5px; font-size:15px" ><?=lang('your_checkoy_progress')?></h2>
	<div class="ui-accordion ui-widget ui-helper-reset" >
		<h2 id="billing_small_head" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" style="line-height: 2; font-size: 11px;"><a href="#" ><?=lang('biling_address')?><span onClick="$('#change_text_0').click();" style="line-height: 24px; font-size: 8px;" id="change_text_small_0"class="right hide" ><?=lang("change_text")?></span></a></h2>
		<div id="billing_small" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
		</div>
		<h2 id="shiping_small_head"  class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" style="line-height: 2; font-size: 11px;" ><a href="#"><?=lang('shiping_address')?><span onClick="$('#change_text_1').click();" style="line-height: 24px; font-size: 8px;" id="change_text_small_1"class="right hide" ><?=lang("change_text")?></span></a></h2>
		<div id="shiping_small" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
		</div>
		<h2 id="shiping_method_small_head" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" style="line-height: 2; font-size: 11px;"><a href="#"><?=lang('shiping_method')?><span onClick="$('#change_text_2').click();" style="line-height: 24px; font-size: 8px;" id="change_text_small_2"class="right hide" ><?=lang("change_text")?></span></a></h2>
		<div id="shiping_method_small" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
		</div>
		<h2  id="shiping_method_small_head"class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" style="line-height: 2; font-size: 11px;"><a href="#"><?=lang('payment_method')?><span onClick="$('#change_text_3').click();"  style="line-height: 24px; font-size: 8px;" id="change_text_small_3"class="right hide" ><?=lang("change_text")?></span></a></h2>
		<div id="payment_method_small" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom">
		</div>
		
	</div>
</div>

	<div class="right" style="width:680px; padding:5px 20px">
	<h1  ><?=lang('checkout')?></h1>
	<div id="accordion" >
		<h3><a href="#" class="toDisable"><?=lang('billing_information')?> <div id="change_text_0" class="right"><?=lang("change_text")?></div></a> </h3>
		<div>
		    <ul class="form-list">        
		       
			<span id="login_container_form" <?php if ($this->session->userdata('logged_in')){ echo 'style="display:none"'	;}?>>
				<li class="fields" style="float:left;margin:0;width:298px;clear:none">
				<div class="ui-widget hide" id="loginFrmValidation_checkout">
					<div class="ui-state-error ui-corner-all" > 
						<p><span class="ui-icon ui-icon-alert"></span> 
						<span class="message_checkout"></span>
						</p>
					</div>
				</div>
				<form id="regiter_form" class="checkoutFrm" style="height:300px " name="regiter_form" method="post" action="<?php echo site_url('user/auth')?>">
					<ul>
		                <li class="fields">
							<div class="field">
								
							<h2 style="margin: 0; font-size: 15px"><?=lang('register')?> </h2>
							<hr>
							<p><?= lang('register_text1') ?></p>
							</div>
							</li>
							<li class="control">
									<input id="user_gues" class="radio validation-passed" type="radio"  title="guess_user" value="1" name="guess_uder">
									<label for="user_gues"><?=lang('guess_user')?></label>
							</li>
						    <li class="control">
								<input id="user_register" class="radio validation-passed" type="radio" title="user_register" value="2" name="guess_uder">
								<label for="user_register"><?=lang('register')?></label>
						   </li>
						   <div class="field">
							<p><?= lang('register_text2') ?></p>

							</div>
							</li>
							<li class="right" style="width:298px">
						<hr>
						
	             			<div class="clear"></div>
							 <a href="JavaScript:guess_user()" class="right">
			                      	<div class="cart_btn_left"></div>
									<div class="cart_btn_midle" style="width: 100px"><?php echo lang('continue') ?></div>
									<div class="cart_btn_right"></div>
				             </a>
							</li>
					</ul>
				</form>
				</li>
				<li class="fields" style="float:left;margin:0;width:298px;clear:none;" >
				<div class="ui-widget hide" id="loginFrmValidation_checkout">
					<div class="ui-state-error ui-corner-all" > 
						<p><span class="ui-icon ui-icon-alert"></span> 
						<span class="message_checkout"></span>
						</p>
					</div>
				</div>
				<form id="loginFrm_checkout" class="checkoutFrm" style="height:300px " name="login_checkout" method="post" action="<?php echo site_url('user/auth')?>">
					<ul>
		                <li class="fields">
		                	<h2 style="margin: 0; font-size: 15px"><?=lang('login')?> </h2>
		                	<hr>
							<div class="field">
								<label for="email_login_checkout"class="required"><em>*</em>Email</label>
								<div class="input-box">
								<input type="text" name="email" id="email_login_checkout" value="" class="" />
								</div>
							</div>
						</li>
		                <li class="fields">
							<div class="field">
								<label for="password_login_checkout" class="required"><em>*</em>Password</label>
								<div class="input-box">
								<input type="password" name="password" id="password_login_checkout" value="" class="" />
								</div>
							</div>
						</li>
						<li class="right" style="width:298px; text" >
						<hr>
						 <span style="color: rgb(255, 0, 0); height: 30px; line-height: 43px;" class="right">* <?=lang('required_filds_lang')?></span>
            				 <div class="clear"></div><br>
						 <a href="JavaScript:loginCheckout()" class="right">
		                      	<div class="cart_btn_left"></div>
								<div class="cart_btn_midle" style="width: 100px"><?php echo lang('login') ?></div>
								<div class="cart_btn_right"></div>
			             </a>
						</li>
					</ul>
				</form>
				</li>
			</span>
			<span id="billing_container_form"<?php if (!$this->session->userdata('logged_in')){ echo 'style="display:none"'	;}			?>>
				
				<li class="wide">
		        <label for="billing-address-select"><?=lang('select_billing_address')?></label>
				<div class="input-box">
					<select name="billing_address_id" id="billing_address_select" class="address-select" title="" style="width: 460px" onchange="newAddress(!this.value)">
							<?php foreach ($address as $itm) {	?>
							<option value="<?php echo $itm->id ; ?>">
							 	 	
								<?php echo  "{$itm->first_name} {$itm->last_name} , {$itm->address} , {$itm->state_provide}, {$itm->postcode}, {$itm->tel_number}"  ;?>
							</option>
							<?php }?>
							<option value="">New Address</option>
					</select>            
				</div>
		        </li> 
		        <form id="billing-form" action="" class="checkoutFrm">
		        <li id="billing-new-address-form">
		            <input type="hidden" name="billing[address_id]" value="" id="billing_address_id" />
		             <input type="hidden" name="billing[new_user]" value="" id="new_user" />
		            
		               <ul class = "hide "id="billing_new_address">
		               <li>
		               	<ul>
							<li class="control left">
								<input class="radio validation-passed" type="radio"  value="1" name="billing[natural_person]">
								<label><?=lang('natural_person')?>&nbsp;&nbsp;&nbsp;</label>
							
								<input class="radio validation-passed" type="radio" checked="checked" value="0" name="billing[natural_person]">
								<label ><?=lang('legal_entity')?></label>
						   </li>
						</ul>
						<div class="clear"></div>
		                <div class="customer-name">
						    <div class="field name-first_name">
						        <label for="billing:first_name" class="required"><em>*</em><?=lang('first_name')?></label>
						        <div class="input-box">
						            <input type="text" id="billing:first_name" name="billing[first_name]" value="" title="First Name" class="input-text required-entry"  />
						        </div>
						    </div>
						    <div class="field name-last_name">
						        <label for="billing:last_name" class="required"><em>*</em><?=lang('last_name')?></label>
						        <div class="input-box">
						            <input type="text" id="billing:last_name" name="billing[last_name]" value="" title="Last Name" class="input-text required-entry"  />
						        </div>
						    </div>
						</div>
						</li>
		                <li class="fields">
		                    <div class="field">
		                        <label for="billing:company"><?=lang('company')?></label>
		                        <div class="input-box">
		                            <input type="text" id="billing:company" name="billing[company]" value="" title="Company" class="input-text" />
		                       	</div>
		                    </div>
		                    <div class="field show_regi_form hide">
		                        <label for="billing:email" class="required"><?=lang('email')?><em>*</em></label></label>
		                        <div class="input-box">
		                            <input type="text" id="billing:email" name="billing[email]" value="" title="email" class="input-text" />
		                       	</div>
		                    </div>
                        </li>
		                <li class="wide">
		                    <label for="billing:address" class="required"><em>*</em><?=lang('address')?></label>
		                    <div class="input-box">
		                        <textarea title="Street Address" name="billing[address]" id="billing:address" class="textarea required-entry" ></textarea>
		                    </div>
		                </li>
		                <li class="fields">
		                    <div class="field">
		                        <label for="billing:city" class="required"><em>*</em><?=lang('city')?></label>
		                        <div class="input-box">
		                            <input type="text" title="City" name="billing[city]" value="" class="input-text required-entry" id="billing:city" />
		                        </div>
		                    </div>
		                    <div class="field">
		                        <label for="billing:state_provide" class="required"><em>*</em><?=lang('state_provide')?></label>
		                        <div class="input-box">
		                            <input type="text" id="billing:state_provide" name="billing[state_provide]" value="" class="input-text" />
		                        </div>
		                    </div>
		                </li>
		                <li class="fields">
		                    <div class="field">
		                        <label for="billing:postcode" class="required"><em>*</em><?=lang('zip_code_postal')?></label>
		                        <div class="input-box">
		                            <input type="text" title="Zip/Postal Code" name="billing[postcode]" id="billing:postcode" value="" class="input-text validate-zip-international required-entry" />
		                        </div>
		                    </div>
		                </li>
		                <li id="meanbee:billing_address_selector">&nbsp;</li>
		
						<li lang="fields">
		                    <div class="field">
		                        <label for="billing:country_id" class="required"><em>*</em><?=lang('country')?></label>
		                        <div class="input-box">
		                            <select class="billing[country_id]" id="billing:country_id" name="billing[country_id]">
									<?php
										foreach ($countries as $country) {
											$flagUrl = IMAGES_URL . 'flags/' . $country->flag;
											if ($sel_country == $country->id) {
												echo '<option selected value="' . $country->id .  '">' . ucfirst($country->name) . '</option>';
											} 
											else {
												echo '<option value="' . $country->id .  '">' . ucfirst($country->name) . '</option>';
											}
										}
									?>
									</select>
		                    	</div>
		                    </div>
		                </li>
		                <li lang="fields">
		                    <div class="field">
		                        <label for="billing:tel_number" class="required"><em>*</em><?=lang('tel_number')?></label>
		                        <div class="input-box">
		                            <input type="text" name="billing[tel_number]" value="" title="tel_number" class="input-text required-entry" id="billing:tel_number" />
		                        </div>
		                    </div>
		                    <div class="field">
		                        <label for="billing:fax"><?=lang('fax')?></label>
		                        <div class="input-box">
		                            <input type="text" name="billing[fax]" value="" class="input-text" id="billing:fax" />
		                        </div>
		                    </div>
		                </li>
		                <li lang="fields">
		                    <div class="field">
		                        <label for="billing:country_id" class="required"><em>*</em><?=lang('how_did_you_find_us')?></label>
		                        <div class="input-box">
		                            <select class="validation-passed" name="billing[how_you_found_us]" id="how_you_found_us">
										<option value=""></option>
										<option value="<?=lang('Returning_customer')?>"><?=lang('Returning_customer')?></option>
										<option selected="selected" value="<?=lang('google_search')?>"><?=lang('google_search')?> </option>
										<option value="<?=lang('recommended_by_a_friend')?>"><?=lang('recommended_by_a_friend')?></option>
										<option value="<?=lang('company_intranet_employee_discount')?>"><?=lang('company_intranet_employee_discount')?></option>
										<option value="<?=lang('magazine_advert')?>"><?=lang('magazine_advert')?></option>
										<option value="<?=lang('bing_msn_search')?>"><?=lang('bing_msn_search')?> </option>
										<option value="<?=lang('yahoo_search')?>"><?=lang('yahoo_search')?></option>
										<option value="<?=lang('other')?>"><?=lang('other')?></option>
										<option value="<?=lang('other_search_engine')?>"><?=lang('other_search_engine')?></option>
									</select>
		                    	</div>
		                    </div>
		                    <div class="field show_regi_form hide">
		                        <label for="billing:email" class="required"><em>*</em><?=lang('password')?></label>
		                        <div class="input-box">
		                            <input type="text" id="billing:email" name="billing[password]" value="" title="password" class="input-text" />
		                       	</div>
		                    </div>
			        	</li>
			        	  <li lang="fields">
		                    <div class="field">
		                        <label for="billing:subscribe"><?=lang('subscribe_to_newsletter')?></label>
		                        <div class="input-box">
		                            <select class="select" name="billing[subscribe]" id="">
										<option value=""></option>
										<option value="1"><?=lang('subscribe_yes')?></option>
										<option value="0"><?=lang('subscribe_no')?> </option>
									</select>
		                    	</div>
		                    </div>
		                      <div class="field hide show_regi_form">
		                        <label for="billing:re_password"class="required"><em>*</em><?=lang('re_password')?></label>
		                        <div class="input-box">
		                            <input type="text" id="billing:re_password" name="billing[re_password]" value="" title="re_password" class="input-text" />
		                       	</div>
		                    </div>
			        	</li>
					</ul>
					<ul>
						<li class="control">
							<input id="use_for_shipping_yes" class="radio validation-passed" type="radio" onclick="billingUseThisToShipping();" title="Ship to this address" value="1" name="billing[use_for_shipping]">
							<label for="billing:use_for_shipping_yes"><?=lang('ship_to_this_address')?></label>
						</li>
					    <li class="control">
							<input id="use_for_shipping_no" class="radio validation-passed" type="radio" onclick="billingDontUseThisToShipping();" title="Ship to different address" checked="checked" value="0" name="billing[use_for_shipping]">
							<label for="billing:use_for_shipping_no"><?=lang('ship_to_different_address')?></label>
					   </li>
					</ul>
		     	</form>
		     	<li>
		     <hr>
             <span style="color: rgb(255, 0, 0); height: 30px; line-height: 43px;" class="right">* <?=lang('required_filds_lang')?></span>
             <br>
			 <br>
			 <br>
             <div class="clear"></div>
			 <div id="billing_content_load" class="right loader hide"></div>
             <a href="JavaScript:saveBiling()" class="right">
                      	<div class="cart_btn_left"></div>
						<div class="cart_btn_midle"><?php echo lang('continue') ?></div>
						<div class="cart_btn_right"></div>
             </a>
             </span>
             </li>	
             </ul>
			</div>
		<h3><a href="#" id="shiping_info_big"  class="toDisable"><?=lang('shiping_info')?> <div id="change_text_1" class="right hide"><?=lang("change_text")?></div></a></h3>
		<div>
			    <ul class="form-list">
			    <form id="shipping-form" action="" class="checkoutFrm">
			          <li class="wide">
			           <label for="shipping-address-select"><?=lang('select_from_addressbook')?></label>
			           <div class="input-box">
			               <select onchange="newAddressShipping(!this.value)" title=""  style="width: 460px"  class="address-select" id="shiping_address_select" name="shipping_address_id">
							<?php foreach ($address as $itm) {	?>
							<option value="<?php echo $itm->id ; ?>">
									<?php echo  "{$itm->first_name} {$itm->last_name} , {$itm->address} , {$itm->state_provide}, {$itm->postcode}, {$itm->tel_number}"  ;?>
							</option>
							<?php }?>
							<option value=""><?=lang('new_address')?></option>
						   </select>           
					   </div>
			      	 </li>
			         <li class="hide" id="shipping_new_address">
			         	<input type="hidden" id="shiping_address_id" value="" name="shipping[address_id]">
				    	<ul>
				        	<li class="fields"><div class="customer-name">
							    <div class="field">
							        <label class="required" for="shipping:first_name"><em>*</em>First Name</label>
							        <div class="input-box">
							            <input type="text" class="input-text required-entry" title="First Name" value="" name="shipping[first_name]" id="shipping:first_name">
							        </div>
							    </div>
							    <div class="field">
							        <label class="required" for="shipping:last_name"><em>*</em>Last Name</label>
							        <div class="input-box">
							            <input type="text" class="input-text required-entry" title="Last Name" value="" name="shipping[last_name]" id="shipping:last_name">
							        </div>
							    </div>
							</div>
							</li>
		                    <li class="fields">
		                        <div class="fields">
		                            <label for="shipping:company">Company</label>
		                            <div class="input-box">
		                                <input type="text" class="input-text" title="Company" value="" name="shipping[company]" id="shipping:company">
		                            </div>
		                        </div>
                            </li>
		                    <li class="wide">
		                        <label class="required" for="shipping:address"><em>*</em>Address</label>
		                        <div class="input-box">
	                       			<textarea title="Street Address" name="shipping[address]" id="shipping:address" class="textarea required-entry" ></textarea>
		                        </div>
		                    </li>
                            <li class="fields">
		                        <div class="field">
		                            <label class="required" for="shipping:city"><em>*</em>City</label>
		                            <div class="input-box">
		                                <input type="text" id="shipping:city" class="input-text required-entry" value="" name="shipping[city]" title="City">
		                            </div>
		                        </div>
		                        <div class="field" id="">
		                            <label class="required" for="shipping:state_provide"><em style="display: none;">*</em>State/Province</label>
		                            <div class="input-box" id="">
		                                <select style="display:none;" class="validate-select" title="State/Province" name="shipping[region_id]" id="shipping:region_id" defaultvalue="">
		                                    <option value="">Please select region, state or province</option>
		                                </select>
		                                <input type="text" style="" class="input-text" title="State/Province" value="" name="shipping[state_provide]" id="shipping:state_provide">
		                            </div>
		                        </div>
		                    </li>
		                    <li class="fields">
		                        <div class="field">
		                            <label class="required" for="shipping:postcode" id=""><em>*</em>Zip/Postal Code</label>
		                            <div class="input-box">
		                                <input type="text" class="input-text validate-zip-international required-entry" value="" id="shipping:postcode" name="shipping[postcode]" title="Zip/Postal Code">
		                            </div>
		                        </div>
		                    </li>
				  			<li lang="fields">
		                        <div class="field">
		                            <label class="required" for="shipping:country_id"><em>*</em>Country</label>
		                            <div class="input-box">
		                                <select title="Country" class="validate-select" id="shipping:country_id" name="shipping[country_id]"><option value="">
		                                <?php
											foreach ($countries as $country) {
												$flagUrl = IMAGES_URL . 'flags/' . $country->flag;
												if ($sel_country == $country->id) {
													echo '<option selected value="' . $country->id .  '">' . ucfirst($country->name) . '</option>';
												} 
												else {
													echo '<option value="' . $country->id .  '">' . ucfirst($country->name) . '</option>';
												}
											}
										?>
		                                </select>                            
		                            </div>
		                        </div>
		                    </li>
		                    <li class="fields">
		                        <div class="field">
		                            <label class="required" for="shipping:tel_number"><em>*</em>Telephone</label>
		                            <div class="input-box">
		                                <input type="text" id="shipping:tel_number" class="input-text required-entry" title="tel_number" value="" name="shipping[telephone]">
		                            </div>
		                        </div>
		                        <div class="field">
		                            <label for="shipping:fax">Fax</label>
		                            <div class="input-box">
		                                <input type="text" id="shipping:fax" class="input-text" title="Fax" value="" name="shipping[fax]">
		                            </div>
		                        </div>
		                    </li>
				    </ul>
			        </li>
	            	 <li class="control">
			            <input type="checkbox" class="checkbox"  title="Use Billing Address" onclick="shippingUseThisToShipping();" value="1" id="same_as_billing" name="shipping[same_as_billing]">
			            <label for="shipping:same_as_billing"><?=lang('using_billing_address')?></label> 
			        </li>
				</ul>
			</form>
			<hr>
			<span style="color: rgb(255, 0, 0); height: 30px; line-height: 43px;" class="right">* <?=lang('required_filds_lang')?></span>
             <br>
			 <br>
			 <br>
             <div class="clear"></div>
			<div id="shipping_content_load" class="right loader hide"></div>
             <a href="JavaScript:saveShipping()" class="right">
                      	<div class="cart_btn_left"></div>
						<div class="cart_btn_midle"><?php echo lang('continue') ?></div>
						<div class="cart_btn_right"></div>
             </a>
		</div>
		<h3 ><a href="#"  id="payment_method_big"  class="toDisable"><?=lang('shiping_method')?> <div id="change_text_2" class="right hide"><?=lang("change_text")?></div></a></h3>
		<div>
        <form action="" id="shipping-method-form"class="checkoutFrm">
       	   <ul class="form-list">
        		<li style="" id="">
			    	<ul>
			    		<?php foreach ($curier as $companies){?>
      					<li class="control">
							<input id="delivery_with_uk" class="radio" type="radio" checked="checked" value="<?=$companies->id?>" name="shipping_method">
							<label for="delivery_with_uk"><?=$companies->name?></label>
					   </li>
					   <? }?>
		             </ul>
				 </li>
             </ul>
			<?php echo lang('shiping_method_text') ?>
		</form>
		<a target="_blank" href="<?php site_url('contact')?>"> <?php echo lang('contact') ?></a> 
		<hr>
			<span style="color: rgb(255, 0, 0); height: 30px; line-height: 43px;" class="right">* <?=lang('required_filds_lang')?></span>
             <br>
			 <br>
			 <br>
             <div class="clear"></div>
			<div id="payment_method_content_load" class="right loader hide"></div>
             <a href="JavaScript:goToPaymentInfo()" class="right">
                      	<div class="cart_btn_left"></div>
						<div class="cart_btn_midle"><?php echo lang('continue') ?></div>
						<div class="cart_btn_right"></div>
             </a>
		</div>
		<h3 ><a href="#"  id="payment_info_big"  ><?=lang('payment_info')?><div id="change_text_3" class="right hide"><?=lang("change_text")?></div></a></h3>
		<div>
        <form action="" id="payment-info-form"class="checkoutFrm">
       	   <ul class="form-list">
        		<li style="" id="">
			    	<ul>
      					<li class="control">
							<input id="credit_card" class="radio" type="radio" checked="checked" value="0" name="payment_info_radio">
							<label for="credit_card"><?=lang('credit_card')?></label>
					   </li>
					   <li class="control">
							<input id="bank_transfer" class="radio" type="radio" value="1" name="payment_info_radio">
							<label for="bank_transfer"><?=lang('bank_transfer')?></label>
					   </li>
		             </ul>
		        </li>
             </ul>
			<?php echo lang('payment_info') ?>
		</form>
		<hr>
			<span style="color: rgb(255, 0, 0); height: 30px; line-height: 43px;" class="right">* <?=lang('required_filds_lang')?></span>
             <br>
			 <br>
			 <br>
             <div class="clear"></div>
			<div id="payment_info_content_load" class="right loader hide"></div>
             <a href="JavaScript:goToReview()" class="right">
                      	<div class="cart_btn_left"></div>
						<div class="cart_btn_midle"><?php echo lang('continue') ?></div>
						<div class="cart_btn_right"></div>
             </a>
		</div>
		<h3><a href="#" id="order_preview"class="checkoutFrm"><?=lang('order_review')?><div id="change_text_4" class="right hide"><?=lang("change_text")?></div></a></h3>	
		<div>
		<div class="cart_container">
	
	<div style="width:100%"> 
		<div class="cartImage  left">&nbsp;</div>
		<div class="left  lpadding10 " style="width: 190px"><?=lang('product_name')?></div>
		<div class="left lpadding10 cartSubtotal"  style="width: 95px"><?=lang('unic_price')?></div>
		<div class="left lpadding10 "><?=lang('qty')?></div>
		<div class="left lpadding10 cartSubtotal" style="width: 95px"><?=lang('subtotal')?></div>
		<div class="clear"></div>
		<hr/>
		
	 </div>	
	<div class="clear"></div>

	<?php echo form_open('cart/updateCart', array('class'=>'checkoutFrm')); 
	$i = 0;
	foreach ($this->cart->contents() as $items){ 
		$i++;
		echo form_hidden($i.'_rowid', $items['rowid']); 
		$productOptiona = $this->cart->product_options($items['rowid'])	?>
			<div class=" left">
				<div class="image-container left">
					<img src="<?php echo ASSETS_URL . 'catalog/small/' . $productOptiona["imageUrl"];?>" />
					<a class="zoom"href="<?php echo (file_exists(LARGE_IMAGE_URL . $productOptiona["imageUrl"]) ? LARGE_IMAGE_URL . $productOptiona["imageUrl"] : NORMAL_IMAGE_URL . $productOptiona["imageUrl"]) ?>"rel="shadowbox"></a>
			    </div>
			</div>	
			<div class="left lpadding10" style="width: 190px">
				<div class="product_name"><?php echo $items['name']; ?></div>
				<?php if ($this->cart->has_options($items['rowid']) == TRUE) { ?>
					<p>
						<?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value){
							if($option_name == 'imageUrl')
								continue;
							?>
							<strong>
							<?php 
							switch ($option_name){
								case 'metal':
									echo lang('cart_metal');
									break;
								case 'colour':
									echo lang('colour');
									break;
								case 'carat_weight':
									echo lang('carat_weight');
									break;
								case 'diamond_size_text':
									echo lang('diamond_size_text');
									break;
								case 'ring_band_width':
									echo lang('ring_band_width');
									break;
								case 'engraving_text':
									echo lang('engraving_text');
									break;
								case 'special_requirements':
									echo lang('special_requirements');
									break;
								case 'ring_size':
									echo lang('ring_size');
									break;
							}
						?>
							:</strong> <?php echo $option_value; ?><br />
						<?php } ?>
					</p>
					<?php } ?>
			</div>	
			<div class="left lpadding10" style="width: 95px">
				<?php echo $this->cart->format_number($exchange->transformPrice($items['subtotal'],$sel_currency, true, 0)) . ' ' . $sel_currency;?>
			</div>	
			<div class="left lpadding10">
				<?php echo form_input(array('name' => $i.'_qty', 'value' => $items['qty'], 'maxlength' => '2', 'size' => '1', 'id'=>'cartInput' , 'disabled'=>'disabled')); ?>
			</div>	
			<div class="left lpadding10" style="width: 95px">
				<?php echo $this->cart->format_number($exchange->transformPrice($items['subtotal'],$sel_currency, true, 0)) . ' ' . $sel_currency;?>
			</div>	
			<div class="clear"></div>
			<hr/>
				<?php 
			
		}
		
		$total = $exchange->transformPrice($this->cart->total(),$sel_currency, true , 0 , $discount_rate);
		echo form_hidden('countItem',$i);
		?>
			
			<div class="right">
				<ul class="cart-list">
					<li class="left-lsit">
						<strong><?=lang('total_price')?></strong>
					</li>
					<li class="right-lsit">
						<?php echo $this->cart->format_number(  $total) . ' ' . $sel_currency;?>
					</li>
				</ul>
				<ul class="cart-list">
					<li class="left-lsit">
						<strong><?=lang('tax')?></strong>
					</li>
					<li class="right-lsit">
						<?php echo $this->cart->format_number($exchange->getTax($this->cart->total(),$sel_currency , $discount_rate)) . ' ' . $sel_currency;?>
					</li>
				</ul>
				<ul class="cart-list">
					<li class="left-lsit">
						<strong><?=lang('discount')?></strong>
					</li>
					<li class="right-lsit">
						<?php echo  $discount_rate; ?>%
					</li>
				</ul>
				<ul class="cart-list special-cart-list">
					<li class="left-lsit">
						<?=lang('grant_total')?>
					</li>
					<li class="right-lsit">
						<?php echo $this->cart->format_number(ceil($total* ($advance_of_maney/100)))  . ' ' . $sel_currency; // * $advance_of_maney /  100?>
					</li>
				</ul>
			</div>
			<div class="clear"></div>
			<hr/>
			<div id="order_preview_content_load" class="right loader hide"></div>
			 <a href="JavaScript:save_order1()" class="right">
					<div class="checkout_btn_left"></div>
					<div class="checkout_btn_midle"><?php echo lang('continue_shop') ?></div>
					<div class="checkout_btn_right"></div>
			</a>
			
		</div>
		</div>
		<h3><a href="#" id="payment_big"  class="toDisable"><?=lang('payment')?><div id="change_text_5" class="right hide"><?=lang("change_text")?></div></a></h3>	
		<div id= "responsePO_content">
			   <form></form>
			   <form target="responsePO" style="padding:0"  action="https://secure2.plationline.ro/trans30.asp" method="post" name="form_po" id="form_po">
					  <?php echo $podata;?>
					  <input type= "hidden" value="<?php echo $sel_currency == 'RON' ? $sel_currency : 'EUR'?>" id="F_Currency" name="F_Currency" />
					  <input type= "hidden" value="" id="f_order_number" name="f_order_number" />
					  <input type= "hidden" value="" id="F_Last_Name" name="F_Last_Name" />
					  <input type= "hidden" value="" id="F_First_Name" name="F_First_Name" />
					  <input type= "hidden" value="" id="F_Country" name="F_Country">
					  <input type= "hidden" value="" id="F_Address" name="F_Address"/>
					  <input type= "hidden" value="" id="F_City" name="F_City"/>
					  <input type= "hidden" value="" id="F_Zip" name="F_Zip" />
					  <input type= "hidden" value="" id="F_State" name="F_State" />
					  <input type= "hidden" value="" id="F_Phone" name="F_Phone"/>
					  <input type= "hidden" value="" id="F_Email" name="F_Email"/>
					  <input type= "hidden" value="1" id="F_Test_Request" name="F_Test_Request"/>
					  <input type= "hidden" value="1" id="F_XML" name="F_XML"/>
					
				</form> 
				<iframe id="responsePO" name="responsePO" style="width:100%;height:735px; border:none;" ></iframe>
				<hr/>
				<div id="payment_big_content_load" class="right loader hide"></div>
				<a href="JavaScript:redirectToOrder();" id="finalRedirect"class="right hide">
                      	<div class="cart_btn_left"></div>
						<div class="cart_btn_midle"><?php echo lang('continue') ?></div>
						<div class="cart_btn_right"></div>
				</a>
		</div>	
	</div>
	<form action="<?=site_url("cart/saveOrder") ?>" id="order_form" style="padding:0">
		<input type="hidden" name="order_billing_id" id="order_billing_id" value=""/>
		<input type="hidden" name="order_shipping_id" id="order_shipping_id" value=""/>
		<input type="hidden" name="order_shipping_method" id="order_shipping_method" value=""/>
		<input type="hidden" name="order_payment_method" id="order_payment_method" value=""/>
		<input type="hidden" name="order_advance_of_maney" id="order_advance_of_maney" value="<?=$advance_of_maney?>"/>
		<input type="hidden" name="order_discount"  id="order_discount" value="<?=$discount_rate?>"/>
	</form>
	<div class="clear"></div>
	</div><!-- End demo -->
</div><!-- Form container -->
<div class="clear"></div>
<script type="text/javascript">
var enableToRedirect = 0;
$(function(){
    $('iframe#responsePO').load(function() {
		enableToRedirect++;
        if (enableToRedirect >= 3) {	
			$('#finalRedirect').show();
		}
    });
});
function redirectToOrder(){
window.location = settings.base_url + lang.lang_key + '/user/my_orders';
}
function save_order1(){
	$('#order_preview_content_load').show();
	save_order();
	if ($("input:radio[name=payment_info_radio]:checked", "#payment-info-form").val() == 1){
		$('#order_preview_content_load').hide();
		window.location = settings.base_url + lang.lang_key + '/user/my_orders';
	} else {
		$('form#form_po').submit();
		available_indexes.push(5);
		  $('iframe#responsePO').load(function() 
			{
				enableToRedirect++;
				$('#order_preview_content_load').hide();
				$('#payment_big').click();
			});
		
	}
}

function guess_user(){
	if ($("input:radio[name=guess_uder]:checked").val()){
		$('#login_container_form').hide();
		$('#billing_container_form').show();
		$('#new_user').val(1);
		$('.show_regi_form').show();
	} else {
		alert('[please_choose_to_register]');
	}  
}
var available_indexes = [0,1,2];
$(document).ready(function() {
	Shadowbox.init();

	if ($('select#billing_address_select').val() == ''){
		newAddress(true);
	}else{
		newAddress(false);
	}
	if ($('select#shiping_address_select').val() == ''){
		newAddressShipping(true);
	} else {
		newAddressShipping(false);
	}
	$("#accordion").accordion({
				icons: false,
				autoHeight: false,
				header: 'h3',
				change: function(event, ui) {
				        var newIndex = $(ui.newHeader).index('h3');
				        var oldIndex = $(ui.oldHeader).index('h3');
				        if (jQuery.inArray(newIndex, available_indexes) == -1) {
				            $(this).children(oldIndex).click();
				            $(this).children(oldIndex).removeClass('ui-state-focus');
				            //$(this).accordion( "activate" , oldIndex ).removeClass('ui-state-focus');
				           // alert('That panel is not yet available');
				        }else {
				        	 $(this).children(newIndex).removeClass('ui-state-focus');
				        	
				        	 if (oldIndex < 4 && oldIndex < newIndex  ){
				        		 $('#change_text_'+newIndex).show();
				        		 $('#change_text_small_'+oldIndex).show();
					        
				        	 }
					    }
				    }
	});
	$("#accordion h3:last").hide();
	$("#responsePO_content").css('padding', '0' );
	$("#billing-form").validate({
		rules: {
			"billing[firstname]" : {
	        	required: true
	        },
	        "billing[lastname]": {
	        	required: true
	        },
	        "billing[street]": {
		    	required: true
		    },
		    "billing[city]": {
	       		required: true
		    },
		    "billing[region]": {
	       		required: true
		    },
		    "billing[postcode]": {
	       		required: true,
	       		number: true
		    },
		    "billing[country_id]": {
	       		required: true
		    },
		    "billing[telephone]": {
	       		required: true,
	       		number: true
		    },
		    "billing[how_you_found_us]": {
		    	required: true
		    },
		}
	});
	$("#shipping-form").validate({
		rules: {
			"shipping[firstname]" : {
	        	required: true
	        },
	        "shipping[lastname]": {
	        	required: true
	        },
	        "shipping[street]": {
		    	required: true
		    },
		    "shipping[city]": {
	       		required: true
		    },
		    "shipping[region]": {
	       		required: true
		    },
		    "shipping[postcode]": {
	       		required: true,
	       		number: true
		    },
		    "shipping[country_id]": {
	       		required: true
		    },
		    "shipping[telephone]": {
	       		required: true,
	       	 	number: true
		    }
		}
	});
	$("#loginFrm_checkout").validate({
		  rules: {
			email: {
			  required: true,
			  email:true
			},
			password: {
			  required: true
			}
		  }
	});	

});
function saveBiling(){
 
  if ($("#billing-form").valid()){
	  $('#billing_content_load').show();
	var data = $('#billing-form').serialize();
	var request = $.ajax({
	  url: settings.base_url + lang.lang_key + '/cart/saveBilling',
	  type: "POST",
	  data: data,
	  dataType: 'json',
	  success: function(data){
		    available_indexes.push(1); 
		 	var billing_small_html= data.first_name+ ' ' + data.last_name+'<br/>'+ data.country_name + '<br/>' + data.address+ '<br/>' + data.city+', '+  data.state_provide+', '+  data.postcode+ '<br/> T:' +data.tel_number;
		 	$('#order_billing_id').val(data.address_id);
		 	$('#F_Last_Name').val(data.first_name);
		 	$('#F_First_Name').val(data.last_name);
		 	$('#F_Country').val(data.code_iso_2);
		 	$('#F_Address').val(data.address);
			$('#F_City').val(data.city);
			$('#F_Zip').val(data.postcode);
			$('#F_State').val(data.state_provide);
			$('#F_Phone').val(data.tel_number);
			$('#F_Email').val(data.email);
			
			$('#shiping_address_select').val(data.address_id);
			$('#billing_small').html(billing_small_html);
			$('#billing_small').addClass('ui-accordion-content-active');
			$('#billing_small_head').removeClass('ui-corner-all');
			$('#billing_small_head').addClass('ui-corner-top');
			$('#billing_address_id').val(data.address_id);
			if (data.new_address) {
			var new_address = data.first_name+ ' ' + data.last_name+', ' + data.address;
				addOption(data.address_id, new_address);
			}
			if ($('#use_for_shipping_yes').is(':checked')){
				if (billingUseThisToShipping() ) {
					saveShipping();
				} 				
			} else {
				$('#shiping_address_id').val($('select#shiping_address_select').val());
				$('#shiping_info_big').click();
				$('#billing_content_load').hide();
			}
		   }
	});
  }
}
function saveShipping(){
	$('#shipping_content_load').show();
	 if ($("#shipping-form").valid()){
		 var data = $('#shipping-form').serialize();
			var request = $.ajax({
				  url: settings.base_url + lang.lang_key + '/cart/saveShipping',
				  type: "POST",
				  data: data,
				  dataType: 'json',
				  success: function(data){
					  	available_indexes.push(2); 
						var shipping_small_html= data.first_name+ ' ' + data.last_name+'<br/>'+ data.country_name + '<br/>' + data.address+ '<br/>' + data.city+', '+  data.state_provide+', '+  data.postcode+ '<br/> T:' +data.tel_number;
						$('#order_shipping_id').val(data.address_id);
						$('#shiping_small').html(shipping_small_html);
						$('#shiping_small').addClass('ui-accordion-content-active');
						$('#shiping_small_head').removeClass('ui-corner-all');
						$('#shiping_small_head').addClass('ui-corner-top');
						$('#shiping_address_id').val(data.address_id);
						$('#payment_method_big').click();
						$('#billing_content_load').hide();
						$('#shipping_content_load').hide();
					   }
				});
	 }
}	
function goToPaymentInfo(){
	$('#payment_method_content_load').show();
	$('#shiping_method_small').html('');
	delivery = ''; 
	$.ajax({
		  url: settings.base_url + lang.lang_key + '/cart/getCurier/' + $("input:radio[name=shipping_method]:checked", "#shipping-method-form").val(),
		  type: "POST",
		  dataType: 'json',
		  success: function(data){
			available_indexes.push(3);
			$('#order_shipping_method').val($("input:radio[name=shipping_method]:checked", "#shipping-method-form").val());
			$('#shiping_method_small').html(data.name + ' <br/>tax: ' + data.tax ); 
			$('#shiping_method_small').addClass('ui-accordion-content-active');
			$('#shiping_method_small_head').removeClass('ui-corner-all');
			$('#shiping_method_small_head').addClass('ui-corner-top');
			$('#payment_info_big').click(); 	
			$('#payment_method_content_load').hide();			
		 }
	});	
	
}
function goToPayment(){
	if ($("input:radio[name=payment_info_radio]:checked", "#payment-info-form").val() == 1){
		save_order();
	} else {
		available_indexes.push(5);
		$('#payment_big').click(); 
	}
	
}
function goToReview() {
	
	$('#payment_info_content_load').show();
	$('#payment_method_small').html('');
	delivery = '';
	delivery = '[credit_card]';
	if (lang.delivery_with_uk != undefined) {
		delivery = lang.credit_card;
	}	
	if ($("input:radio[name=payment_info_radio]:checked", "#payment-info-form").val() == 1){
		delivery = '[bank_transfer]';
		if (lang.delivery_with_uk != undefined) {
			delivery = lang.bank_transfer;
		}
		
	}	
	available_indexes.push(4);
	if ($("input:radio[name=payment_info_radio]:checked", "#payment-info-form").val() == 0){
		$("#accordion h3:last").show();
	} else {
		$("#accordion h3:last").hide();
	}
	$('#order_payment_method').val($("input:radio[name=payment_info_radio]:checked", "#payment-info-form").val());
	$('#payment_method_small').html(delivery); 
	$('#payment_method_small').addClass('ui-accordion-content-active');
	$('#payment_method_small_head').removeClass('ui-corner-all');
	$('#payment_method_small_head').addClass('ui-corner-top');
	$('#order_preview').click(); 
	$('#payment_info_content_load').hide();
}
function save_order(){	
	var data = $('#order_form').serialize();
	var request = $.ajax({
	  url: settings.base_url + lang.lang_key + '/cart/saveOrder',
	  type: "POST",
	  data: data,
	  dataType: 'json',
	  success: function(data){
			$('#f_order_number').val(data.order_id);
		   }
	});
}
function loginCheckout() {
	$('#loginFrmValidation_checkout').hide();
	if ($("#loginFrm_checkout").valid()){	
	$.ajax({
		url: settings.base_url + lang.lang_key + '/user/auth/',
		dataType: 'json',
		type: 'POST',
		data: {'email' : $('#email_login_checkout').val(), 'password' : $('#password_login_checkout').val()},
		success: function(data){
			if (!data.status) {
				$('#loginFrmValidation_checkout .message_checkout').html(data.message);
				$('#loginFrmValidation_checkout').show();
				return false;
			}
			
			window.location.reload();
		},
		complete: function() {
		}
	});	
	}									
}

function newAddress(newAdd) {
	if (!newAdd) {
		$('#billing_new_address').hide();
		$('#billing_address_id').val($('select#billing_address_select').val()) ;
	} else {
		$('#billing_new_address').show();
		$('#billing_address_id').val('');
	}
}
function newAddressShipping(newAdd) {
	if (!newAdd) {
		$('#shipping_new_address').hide();	
		$('#shiping_address_id').val($('select#shiping_address_select').val());
	} else {
		$('#shipping_new_address').show();
		$('#shiping_address_id').val('');
	}
}
function billingUseThisToShipping(){
	$('#same_as_billing').attr('checked', true);
	$('#shipping_new_address').hide();	
	$('#shiping_address_id').val($('#billing_address_id').val());
	$('select#shiping_address_select').val($('#billing_address_id').val());
	return true;
}
function billingDontUseThisToShipping(){
	$('#shiping_address_id').val('');
	$('#same_as_billing').attr('checked', false)
}
function shippingUseThisToShipping(){
	$('#shipping_new_address').hide();
	$('#shiping_address_id').val($('#billing_address_id').val());
	$('select#shiping_address_select').val($('#billing_address_id').val())	
}
function addOption(id, text){
	$("#shiping_address_select").prepend("<option value='"+id+"' >"+text+"</option>");
	$('#billing_address_select').prepend("<option value='"+id+"' >"+text+"</option>");
}
</script>

<div class="clear"></div>